package com.wang.project.service;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wang.project.common.DeleteRequest;
import com.wang.project.model.dto.user.*;
import com.wang.project.model.entity.User;
import com.wang.project.model.vo.UserVO;
import io.minio.errors.*;
import org.springframework.web.multipart.MultipartFile;


import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.List;

/**
 * 用户服务
 *
 * @author yupi
 */
public interface UserService extends IService<User> {

    /**
     * 用户注册
     *
     * @return 新用户 id
     */
    long userRegister(UserRegisterRequest userRegisterRequest);

    /**
     * 用户登录
     *
     * @param request
     * @return 脱敏后的用户信息
     */
    User userLogin(UserLoginRequest userLoginRequest, HttpServletRequest request);


    /**
     * 用户邮箱登录
     *
     * @param userEmailLoginRequest
     * @param request
     * @return
     */
    User userEmailLogin(UserEmailLoginRequest userEmailLoginRequest, HttpServletRequest request);


    /**
     * 获取当前登录用户
     *
     * @param request
     * @return
     */
    User getLoginUser(HttpServletRequest request);

    /**
     * 是否为管理员
     *
     * @param request
     * @return
     */
    boolean isAdmin(HttpServletRequest request);

    /**
     * 用户注销
     *
     * @param request
     * @return
     */
    boolean userLogout(HttpServletRequest request);

    /**
     * 获取用户列表
     *
     * @param userQueryRequest
     * @param request
     * @return
     */
    List<UserVO> listUser(UserQueryRequest userQueryRequest, HttpServletRequest request);

    /**
     * 分页获取用户列表
     */
    Page<UserVO> listUserByPage(UserQueryRequest userQueryRequest, HttpServletRequest request);


    /**
     * 更新用户信息
     *
     * @param file              用户头像
     * @param userUpdateRequest
     * @param request
     * @return
     */
    Boolean updateUser(MultipartFile file, UserUpdateRequest userUpdateRequest, HttpServletRequest request) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException;

    /**
     * 获取邮箱验证码
     *
     * @param userEmailLoginRequest
     * @return
     */
    String getEmailVerificationCode(UserEmailLoginRequest userEmailLoginRequest);

    /**
     * 获取当前登录用户
     *
     * @param id
     * @param request
     * @return
     */
    UserVO getUserById(int id, HttpServletRequest request) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException;

    Boolean deleteUser(DeleteRequest deleteRequest, HttpServletRequest request);
}
